package cn.whut.glab.dao;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import cn.whut.glab.domain.BD_User;
import cn.whut.glab.utils.DataSourceUtils;

public class UserDao {
	public String getPassword(String userName) throws SQLException{
		QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
		String sql="select password from bd_user where userName='"+userName+"'";
		return (String) runner.query(sql, new ScalarHandler());
	}
	
	public void changPassword(String userName,String password) throws SQLException{
		QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
		String sql="update bd_user set password='"+password+"' where userName='"+userName+"'";
		//System.out.println(sql);
		runner.update(sql);
	}
}
